<template>
<div>
     <Modal v-model="modal" :title="title" :styles="{width:'1100px',top:'20px'}">
        <Row :gutter="20">
            <!-- <Col span="6">
                <Tree :data="data2" ref="tree" @on-select-change="change"></Tree>
                
            </Col> -->
            <Col span="24">
                <Row :gutter="20">
                    <Col span="6">
                        <Input v-model="search.paramData.spmc" placeholder="名称" ></Input>
                    </Col>
                    
                    <Col span="15">
                        <Button type="primary" icon="ios-search" @click="getdata('search')">搜索</Button>
                        <!-- <Button type="primary" @click="refresh" >同步</Button> -->
                    </Col>
                    <Col span="3">
                        
                    </Col>
                </Row>
                <div style="margin-top:20px;">
                    <div class="ivu-table-wrapper" >
                        <div class="ivu-table ivu-table-with-fixed-top ">
                            <div class="ivu-table-body" >
                                <table  class="table_border _table"   cellspacing="0" cellpadding="0" border="0" style="width: 100%;">
                                   
                                    <thead>
                                        <tr>
                                            <th class="" style="width:170px;">
                                                <div class="ivu-table-cell">
                                                    <span>  编码</span>
                                                </div>
                                            </th>
                                            <th class="" style="width:120px;">
                                                <div class="ivu-table-cell">
                                                    <span>名称</span>
                                                </div>
                                            </th>
                                            <th class="" style="width:350px;">
                                                <div class="ivu-table-cell">
                                                    <span>说明</span>
                                                </div>
                                            </th>
                                            <th class="" style="width:60px;">
                                                <div class="ivu-table-cell">
                                                    <span>税率</span>
                                                </div>
                                            </th>
                                            <th class="">
                                                <div class="ivu-table-cell">
                                                    <span>  关键字    </span>
                                                </div>
                                            </th>
                                            <th class="" style="width:80px;">
                                                <div class="ivu-table-cell">
                                                    <span>  操作    </span>
                                                </div>
                                            </th>
                                        </tr>
                                    </thead>
                                    <tbody class="ivu-table-tbody">
                                        <tr class="ivu-table-row" v-for="(item,index) in data">
                                            <td class="">
                                                <div class="ivu-table-cell">
                                                    <span>{{item.spbm}}</span>
                                                </div>
                                            </td>
                                            <td class="">
                                                <div class="ivu-table-cell">
                                                    <span>  {{item.spmc}}</span>
                                                </div>
                                            </td>
                                            <td class="">
                                                <div class="ivu-table-cell">
                                                    <span>  {{item.sm}}</span>
                                                </div>
                                            </td>
                                            <td class="">
                                                <div class="ivu-table-cell">
                                                   {{item.zzssl}}
                                                </div>
                                            </td>
                                            <td class="">
                                                <div class="ivu-table-cell">
                                                   {{item.gjz}}
                                                </div>
                                            </td>
                                            <td class="">
                                                <div class="ivu-table-cell">
                                                    <Button  size="small" type="primary" 
                                                    @click="check(item)">选择</Button>
                                                </div>
                                            </td>
                                        </tr>
                                    </tbody>
                                </table>
                                <div class="body_empty" v-if="data.length==0 ">
                                    暂无数据
                                </div>
                            </div>
                        </div>
                        
                    </div>
                </div>
                <p style="margin-top:20px;">
                    <Page :total="page.total" :current="search.pageNo" placement="top" :page-size="search.pageSize"   @on-change="changePage" show-total style="float: right;"></Page>
                </p>
            </Col>
        </Row>
     </Modal>
</div>
</template>
<script>
 export default {
     data (){
        return {
            modal:false,value:'',title:'对码',
            search:{paramData:{spmc:''},pageNo:0,pageSize:10},
            data2:[
                {title:'税政分类编码',id:1,expand:true,children:[
                    {title:'货物'},
                    {title:'劳务'},
                    {title:'服务'}
                ]}
            ],
            page:{total:0},
            data:[
                
            ]
        }
    },mounted(){
        $('._table').resizableColumns({});
    },methods:{
         showdata(params){
            //this.guid=params;
            this.modal=true;
            this.data=[];
            this.getdata();
         },
        changePage (pageNum){
            this.search.pageNo = pageNum;
            this.getdata();
        },cancel(){
            this.modal=false;
        },getdata(type){
            if(type=='search'){
                this.search.pageNo=1;
            }
            this.axios.post('/comoffical/queryList',this.search).then((res)=>{
                console.log(res);
                // this.data=res.goods;
                // this.search.currentPage=res.pageNum || 1;
                // this.page.total=res.total || 0;
                var d=res.data.list;
				
				this.data=d;
				this.page.total=res.data.total;
				//this.search.pageSize=res.data.pageSize
				this.search.pageNo=res.data.pageNo || 1;
            })
        },check(item){
            this.$emit('refresh',item);
            this.modal=false;
        },getuser(){
            this.axios.post('/user/findbypage',this.page).then((res)=>{
                console.log(res);
                if(res.errorCode==0){
                    this.data=res.data.list;
                    this.page.total=res.data.total || 0;
                    this.search.currentPage=res.data.pageNo || 0;
                }
            })
        },change(){
            var d=this.$refs.tree.getSelectedNodes();
            this.page.orgGuid=d[0].guid;
            this.getuser();
        },refresh(){
            const msg = this.$Message.loading({
                    content: 'Loading...',
                    duration: 0
            });
            //console.log(msg)
            this.axios.post('/user/officalgoods/update',{timeout:20*1000}).then((res)=>{
                console.log(res);
                msg();
                if(res.errorCode==0){
                    this.data=[];
                    this.getdata();
                }
            })
        }
    },created(){
         this.$bus.on('bus_libraryedit', this.showdata);
         
    },beforeDestroy(){
         this.$bus.off('bus_libraryedit',this.showdata)
     }
 }
</script>
